package com.owc.common.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author Jackies
 * @Date 2019/12/3 20:20
 * @Description TODO://
 **/
public enum LoginTypeEnum {
    AUTH_CODE(1,"验证码登录"),
    PASSWORD_TYPE(2,"密码登录");

    private Integer type;

    private String desc;

    LoginTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * Find client enum by client type.
     * @param type type
     * @return Client enum example.
     */
    public static Optional<LoginTypeEnum> match(Integer type) {
        return Arrays.stream(LoginTypeEnum.values())
                .filter(t -> t.getType().equals(type))
                .findFirst();
    }
}
